#ifndef _OSTREAM_HH_
#define _OSTREAM_HH_

// c++
#include <chrono>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <thread>

// synchronize use of cout, and print thread info
#define LOG_COUT_BEGIN {                                            \
        std::lock_guard<std::mutex> lock(Mage::_cout_mutex);        \
        std::time_t now =                                           \
            std::chrono::system_clock::to_time_t(                   \
                std::chrono::system_clock::now());                  \
        std::cout << std::put_time(std::localtime(&now), "%c\t");   \
        std::cout << "[" << std::this_thread::get_id() << "]\t"

#define LOG_COUT_ENDL std::endl; }

namespace Mage {

extern std::mutex _cout_mutex;

} // namespace Mage

#endif // _OSTREAM_HH_
